Class Location

java.lang.Object
edu.uky.ai.path.Location
Direct Known Subclasses:
Path, Sprite

public class Location
extends java.lang.Object
A location is anything with an x and y coordinate in 2D space.
Author:
Stephen G. Ware
  • Field Summary

    Fields 
    Modifier and Type Field Description
    protected Map map
    The map on which this location appears.
    boolean solid
    Whether or not the location contains an impassable wall
    protected int x
    The horizontal position
    protected int y
    The vertical position
  • Constructor Summary

    Constructors 
    Constructor Description
    Location​(Map map, int x, int y, boolean solid)
    Creates a new location.
  • Method Summary

    Modifier and Type Method Description
    boolean equals​(java.lang.Object other)  
    int getX()
    Return the horizontal position of this object.
    int getY()
    Return the vertical position of this object.
    int hashCode()  
    java.lang.Iterable<Location> neighbors()
    Returns all locations around this object which are accessible by one step north, south, east, or west.
    java.lang.String toString()  

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Field Details

    • map

      protected final Map map
      The map on which this location appears.
    • x

      protected int x
      The horizontal position
    • y

      protected int y
      The vertical position
    • solid

      public final boolean solid
      Whether or not the location contains an impassable wall
  • Constructor Details

    • Location

      public Location​(Map map, int x, int y, boolean solid)
      Creates a new location.
      Parameters:
      map - the map on which this location appears
      x - the horizontal location
      y - the vertical location
      solid - whether or not the location contains a wall
  • Method Details

    • equals

      public boolean equals​(java.lang.Object other)
      Overrides:
      equals in class java.lang.Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class java.lang.Object
    • toString

      public java.lang.String toString()
      Overrides:
      toString in class java.lang.Object
    • getX

      public int getX()
      Return the horizontal position of this object.
      Returns:
      the horizontal position
    • getY

      public int getY()
      Return the vertical position of this object.
      Returns:
      the vertical position
    • neighbors

      public java.lang.Iterable<Location> neighbors()
      Returns all locations around this object which are accessible by one step north, south, east, or west.
      Returns:
      all neighboring locations